import type { MenuItem as RouteMenuItem } from "../types/menu";

// 登录参数接口
export interface LoginParams {
  username: string;
  password: string;
}

// API 响应接口
export interface ApiResponse<T = unknown> {
  status: number;
  msg: string;
  data: T;
}

// 后端返回的菜单项接口
export interface ApiMenuItem {
  id: number;
  parentId: number;
  menuName: string;
  url: string | null;
  description: string | null;
  editAble: number;
  menuList: ApiMenuItem[] | null;
  component?: string;
}

// 前端使用的菜单项接口
export interface MenuItem extends Omit<RouteMenuItem, "component"> {
  component?: string;
  icon?: string;
}

// 角色接口
export interface Role {
  id: string | number;
  name: string;
  menuList: ApiMenuItem[];
  token?: string;
}

// 登录响应接口
export interface LoginResponse {
  id: number;
  username: string;
  fullName: string;
  password: string;
  tel: string;
  createTime: string | null;
  modifyTime: string | null;
  status: number;
  role: Role;
  token: string;
}

// 用户信息接口
export interface UserInfo {
  id: number;
  username: string;
  fullName: string;
  tel: string;
  role: Role;
}

// 文件接口
export interface FileItem {
  id: number;
  fileName: string;
  filePath: string;
  fileUrl: string | null;
  updateTime: string;
}

// 操作日志接口
export interface OperationLogItem {
  id: number;
  operatorEvent: string;
  operatorResult: string;
  operatorTime: string;
  operatorUser: string;
  operatorUserId: number;
}

// 分页响应接口
export interface PaginationResponse<T> {
  current: number;
  pages: number;
  records: T[];
  size: number;
  total: number;
}

// 常用的 API 端点常量
export const API_ENDPOINTS = {
  // 用户相关
  USER_LOGIN: "/api/user/login",
  USER_INFO: "/api/user/info",
  USER_LOGOUT: "/api/user/logout",
  USER_LIST: "/api/user/userList",
  USER_UPDATE: "/api/user/update",
  USER_SAVE: "/api/user/save",
  USER_DELETE: "/api/user/del",

  // 菜单相关
  MENU_SAVE: "/api/menu/save",
  MENU_DELETE: "/api/menu/del",

  // 文件相关
  FILE_UPLOAD: "/api/uploadFile/uploadFile",
  FILE_LIST: "/api/uploadFile/getFileList",
  FILE_SEARCH: "/api/uploadFile/searchFile",
  FILE_DELETE: "/api/uploadFile/deleteFile",

  // 操作日志
  OPERATION_LOG_LIST: "/api/operator/operatorLogList",
} as const;
